// store.js
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export function createStore() {
  return new Vuex.Store({
    state: {
      number: undefined,
    },
    actions: {
      GET_NUMBER({ commit }, number) {
        return new Promise(resolve => {
          setTimeout(() => {
            resolve(commit('SET_NUMBER', number + 1))
          }, 1000)
        })
      },
    },
    mutations: {
      SET_NUMBER(state, number) {
        state.number = number
      }
    },
  })
}